import {
  Table,
  Model,
  Column,
  DataType,
  ForeignKey,
  BelongsTo,
  // HasMany,
  PrimaryKey,
  AutoIncrement,
  Unique,
  AllowNull,
  Comment,
} from 'sequelize-typescript';
import { User } from './user.entity';
// import { Visitor } from './visitor.entity';

@Table({
  tableName: 'house',
  comment: '房屋表',
})
export class House extends Model {
  @PrimaryKey
  @AutoIncrement
  @Unique
  @AllowNull(false)
  @Comment('房屋id')
  @Column(DataType.BIGINT)
  id: number;

  @AllowNull(false)
  @Comment('小区坐标')
  @Column(DataType.STRING)
  point: string;

  @AllowNull(false)
  @Comment('小区名称')
  @Column(DataType.STRING(100))
  pointName: string;

  @AllowNull(false)
  @Comment('小区楼栋信息')
  @Column(DataType.STRING(100))
  building: string;

  @AllowNull(false)
  @Comment('小区房间信息')
  @Column(DataType.STRING(100))
  room: string;

  @AllowNull(false)
  @Comment('身份证正面照')
  @Column(DataType.STRING)
  idcardFrontUrl: string;

  @AllowNull(false)
  @Comment('身份证反面照')
  @Column(DataType.STRING)
  idcardBackUrl: string;

  @AllowNull(false)
  @Comment('状态：1审核中2审核成功3审核失败')
  @Column({
    type: DataType.ENUM('1', '2', '3'),
    defaultValue: '1',
  })
  status: number;

  @ForeignKey(() => User)
  @Column(DataType.BIGINT)
  userId: number;

  @BelongsTo(() => User) // 指定这是一个属于（BelongsTo）关系
  user: User;

  // @HasMany(() => Visitor)
  // visitors: Visitor[];
}
